<?php

/**
 * Credentials main page
 * @package ModuleAdministratif
 * @version 1.0b
 */

session_start();

// Configuration file
include 'configuration.php';
// Functions
include 'inc/functions.php';

// Checking if user is logged in
if (!CheckSession()):
	header('Location: index.php');
	exit();
endif;

// Include all objects
foreach (glob($configuration['webroot'].'objects/*.php') as $class) { include_once $class; }

// ---------- START: HEAD
include $configuration['webroot'].'inc/head.php';
// ---------- END: HEAD

// ---------- START: MENU
include $configuration['webroot'].'inc/menu.php';
// ---------- END: MENU

// ---------- START: BODY

$credentials = new Credentials();
$credentialsList = $credentials->GetList(Array(Array('credentialsId', '>', '0')), 'name'); ?>

<form action="" method ="post" class="form-crud">
<h3 class="subtitle">Rôles</h3>
<table cellpadding="0" cellspacing="0" border="0" class="table-objects" id="table-credentials">
	<?php foreach ($credentialsList as $credentials) {
		$res  = '<tr>';
		$res .= '<td class="del"><a href="'.$credentials->credentialsId.'" class="delete-doc delete-credentials"><img src="css/img/bin_empty.png" alt="Delete" /></a></td>';
		$res .= '<td>'.$credentials->name.'</td>';
		$res .= '</tr>';
		echo $res;
	} ?>
	<tr>
		<td class="form-crud-label"><a href="#" id="credentials-add" class="new">Ajouter</a></td>
		<td class="form-crud-input"></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
</table>
</form>

<div id="credentials_form" class="hidden"></div>

<?php
// ---------- END: BODY

// ---------- START: FOOT
include $configuration['webroot'].'inc/foot.php';
// ---------- END: FOOT

// ---------- JAVASCRIPTS AND END
include $configuration['webroot'].'inc/js.php'; ?>
<script type="text/javascript" src="js/credentials.js"></script>

</body>
</html>